<?php
require_once dirname(__FILE__).'/../../banners/lib/BannersHelper.class.php';

class galleryListComponents extends myComponents{
	
	public function executeRender(){

		$this->pager = $this->getPager();
		$this->bannersHelper = new BannersHelper();
		$this->node = $this->getRoute()->getObject();

	}

	public function getPager(){
		$pager = new sfDoctrinePager('BannerGroup', 4);
  		$pager->setQuery( $this->getGalleryQuery() );
  		$pager->setPage($this->getRequestParameter('page', 1));
  		$pager->init();

		return $pager;
	}

	public function getGalleryQuery(){
		$q = Doctrine::getTable('BannerGroup')
			->createQuery('asdaksd;')
			->select('bg.*, b.*')
			->from('BannerGroup bg')
			->innerJoin('bg.StructureBannerGroups bgs WITH bgs.structure_id = ?',
					$this->getRoute()->getObject()->getId())
			->innerJoin('bg.Banners b')
			->andWhere('bg.type = ?', 'default')
			->orderBy('bg.pri asc')
			->addOrderBy('b.pri asc');



		return $q;
	}
}
